package cn.myschool.admin2.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Service;

/**
 * @author oldliu
 * @since 1.0
 */
@Service
@Aspect
public class SchoolInterceptor {

    @Around("within(cn.myschool.admin2.dao..*)")
    public Object doIntercept(ProceedingJoinPoint p){
        long start=System.nanoTime();
        try{
            Object obj = p.proceed();//doFilter
            return obj;
        }catch (Throwable e){
            e.printStackTrace();
            throw new RuntimeException(e);
        }finally {
            long end=System.nanoTime();
            System.out.println(p.getSignature().getName()+"执行， 耗费时间"+(end-start)+"纳秒");
        }
       // return null;
    }
}
